package cn.congzhou.crm.domain;

import cn.congzhou.crm.utils.Constants;
import lombok.*;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

@Getter@Setter@ToString
@AllArgsConstructor
@NoArgsConstructor
public class Employee implements Serializable{
    private Long id;

    private String sid;//员工号/账号

    private String name;

    private Integer gender;//性别

    private String password;

    private String phone;//电话

    private String idno;//身份证号

    private Integer age;

    private boolean admin;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date hireDate;//入职日期

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date quitDate;//离职日期

    private Integer status;//员工状态

    private School school;

    private Department dept;

    private List<Role> roles;

    //  转换性别为字符串
    public String getGenderName(){
        if(gender == null){
            return "";
        }
        if(gender == 0){
            return "女";
        }else if(gender == 1){
            return "男";
        }
        return "";
    }

    public String getStatusName(){
        if(status == null){
            return "";
        }
        if(status == Constants.EMP_STATUS_QUIT){
            return "离职";
        }else if(status == Constants.EMP_STATUS_NORMAL) {
            return  "在职";
        }else if(status == Constants.EMP_STATUS_LOCK) {
            return "锁定";
        }else if(status == Constants.EMP_STATUS_DISABLE){
            return "禁用";
        }
        return "";
    }

    public String getJson(){

        return null;
    }

}